import { Component, OnInit } from '@angular/core';
import { Fuhao } from './fuhao';
import { FuhaoDetailComponent } from './fuhao-detail.component';
import { FuhaoService } from './fuhao.service';
import { Router } from '@angular/router';



@Component({
	selector: 'my-fuhaos',
	directives: [FuhaoDetailComponent],
	templateUrl: 'app/fuhaos.component.html',
    styleUrls: ['app/fuhaos.component.css']
})
export class FuhaosComponent implements OnInit{
  constructor(
  private fuhaoService:FuhaoService,
  private router: Router
  ) { }
  title = '富豪排行榜';
  fuhaos: Fuhao[];
  selectedFuhao: Fuhao;
  ngOnInit() {
	this.fuhaoService.getFuhaos().then(fuhaos => this.fuhaos = fuhaos);
	}
  onSelect(fuhao: Fuhao) { 
    this.selectedFuhao = fuhao;
    this.router.navigate(['/detail', this.selectedFuhao.id]);
  }
}